<include file="Public/head" />
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<style type="text/css">
    .employee .employee_left,.employee_right{width: 50%;float:left;}
    .select2-container .select2-choice > .select2-chosen{text-align: center;}
</style>
</head>
<body>
<include file="Public/common_header" />

<div class="mian">
    <include file="Public/sidebar" menu='xtgl.jtj4sdgl' />
    <form action="/fours/add_fm" method="post" id="fm" >
        <div class="mianR">
            <h3 class="yonghu">4s店管理-添加</h3>
            <div class="shangFrom shangFrom1 clearfix">
                <div class="chang-ci">
                </div>
            </div>
            <div class="employee">
                <div class="employee_left">
                    <ul class="clearfix">
                        <li>
                            <span>*4S店名称：</span>
                            <input type="text" name="f_name" value="" />
                        </li>
                        <li>
                            <span>4S店地址：</span>
                            <input type="text" name="addr" value="" />
                        </li>
                        <li>
                            <span>联系人：</span>
                            <input type="text" name="contact"  value="" />
                        </li>
                        <li>
                            <span>联系电话：</span>
                            <input type="text" name="phone"  value="" />
                        </li>
                        <li>
                            <span>请选择分公司：</span>
                            <select name="branch_company" id="branch_company">
                                <option value="0">请选择分公司</option>
                                <foreach name="bc_list" item="val" key="key" >
                                    <option value="{$key}">{$val}</option>
                                </foreach>
                            </select>
                        </li>
                        <li>
                            <span>4S开发人：</span>
                            <select name="developer" id="developer">
                                <option value='0'>请选择开发人</option>
                            </select>
                        </li>
                        <li>
                            <span>*所在城市：</span>
                            <select name="bc_city" id="bc_city" >
                                <foreach name="bc_city" item="v" key="k" >
                                    <option value="{$k}" >{$v}</option>
                                </foreach>
                            </select>
                        </li>
                        <li>
                            <span>所属集团：</span>
                            <select name="b_id" id="bid">
                                <option value="">请选择所属集团</option>
                                <volist name='allbloc' id='bloc'>
                                    <option value="{$bloc.bid}">{$bloc.b_name}</option>
                                </volist>
                            </select>
                        </li>
                    </ul>
                </div>
                <div class="employee_right">
                    <ul class="clearfix">
                        <?php if ($edit_auth): ?>
                            <li>
                                <span>*开户银行1：</span>
                                <input type="text" name="bank_name"  value="" />
                            </li>
                            <li>
                                <span>*银行账号1：</span>
                                <input type="text" name="card_no"  value="" />
                            </li>
                            <li>
                                <span>*账户名1：</span>
                                <input type="text" name="account_name"  value="" />
                            </li>
                            <li>
                                <span>开户银行2：</span>
                                <input type="text" name="bank_name_1"  value="" />
                            </li>
                            <li>
                                <span>银行账号2：</span>
                                <input type="text" name="card_no_1"  value="" />
                            </li>
                            <li>
                                <span>账户名2：</span>
                                <input type="text" name="account_name_1"  value="" />
                            </li>
                        <?php else : ?>
                            <li>
                                <span>*开户银行：</span>
                                <input type="text" name="bank_name"  value="" />
                            </li>
                            <li>
                                <span>*银行账号：</span>
                                <input type="text" name="card_no"  value="" />
                            </li>
                            <li>
                                <span>*账户名：</span>
                                <input type="text" name="account_name"  value="" />
                            </li>
                        <?php endif ?>
                    </ul>
                </div>
                <div class="clear"></div>
            </div>
            <div class="yongBtn">
                <input type="button" onclick="return Submit();" value="确定" class="queding" />
                <input name="重置" type="reset" class="quxiao" onclick="history.go(-1);" value="取消" />
            </div>
        </div>
    </form>
</div>
<script>
    $("#bid").select2();
    $("#bc_city").select2();
    $("#branch_company").select2();
    $("#developer").select2();

    $("#branch_company").change(function () {
        var branch_company_id = $(this).val();
        $.post("/Fours/get_shop_developer", {"branch_company_id": branch_company_id}, function (data) {
            var optstr = '';
            if (data.code == 200) {
                $.each(data.data, function (k, val) {
                    optstr += "<option value='" + val.emp_id + "'>" + val.real_name + "</option>"
                });
            }
            optstr = "<option value='0' selected='selected'>请选择开发人</option>" + optstr;
            $("#developer").html(optstr).select2();
        }, "json");
    });


    function Submit(){
        post_submit_json('fm',function(data){
            //成功回调
            if (data.code == 200) {
                btn_alert("新增成功",1000,function(){
                    location.href = document.referrer;
                });
            }else{
                shibai_alert(data.msg);
            }
           
        })    
        return false;
    }

</script>
<include file="Public/foot" />